import request from './request'

// 获取比赛项目列表（分页）
export const getEventList = (params) => {
  return request.get('/event/list', { params })
}

// 获取比赛项目列表（不分页）
export const getEventListSimple = (params) => {
  return request.get('/event/simple', { params })
}

// 获取比赛项目详情
export const getEventDetail = (id) => {
  return request.get(`/event/${id}`)
}

// 创建比赛项目
export const createEvent = (data) => {
  return request.post('/event', data)
}

// 更新比赛项目信息
export const updateEvent = (id, data) => {
  return request.put(`/event/${id}`, data)
}

// 删除比赛项目
export const deleteEvent = (id) => {
  return request.delete(`/event/${id}`)
}

// 批量删除比赛项目
export const batchDeleteEvents = (ids) => {
  return request.delete('/event/batch', { data: { ids } })
}

// 启用/禁用比赛项目
export const toggleEventStatus = (id, status) => {
  return request.put(`/event/${id}/status`, { status })
}

// 导入比赛项目
export const importEvents = (data) => {
  return request.post('/event/import', data)
}

// 导出比赛项目
export const exportEvents = (params) => {
  return request.get('/event/export', { params, responseType: 'blob' })
}

// 获取项目分配的裁判员
export const getEventJudges = (eventId) => {
  return request.get(`/event/${eventId}/judges`)
}

// 为项目分配裁判员
export const assignJudgesToEvent = (eventId, judgeIds) => {
  return request.post(`/event/${eventId}/judges`, { judgeIds })
}

// 移除项目的裁判员分配
export const removeJudgesFromEvent = (eventId, judgeIds) => {
  return request.delete(`/event/${eventId}/judges`, { data: { judgeIds } })
}
